package com.autumn.oauth2.zero;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;

import com.autumn.oauth2.zero.configuration.AuthorizationServerDefinitionRegister;
import com.autumn.oauth2.zero.configuration.AuthorizationServerEndpointConfiguration;
import com.autumn.oauth2.zero.configure.ZeroAuthenticationSecurityConfigurerAdapter;
import com.autumn.oauth2.zero.configure.ZoreAuthorizationServerConfigurerAdapter;
import com.autumn.oauth2.zero.userdetails.identity.AutumnUserServiceImpl;
import com.autumn.redis.EnableAutumnRedis;
import com.autumn.security.core.userdetails.IAutumnUserDetailsService;
import com.autumn.security.crypto.AutumnUserDetailsBindingPasswordProvider;
import com.autumn.security.crypto.IAutumnPasswordProvider;

/**
 * 启用 Autumn 授权服务器
 * 
 * @author 老码农
 *
 *         2018-04-12 18:42:14
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@EnableAuthorizationServer
@EnableAutumnRedis
@Import({ AuthorizationServerDefinitionRegister.class, AuthorizationServerEndpointConfiguration.class })
public @interface EnableAutumnAuthorizationServer {

	/**
	 * 用户服务类型
	 * 
	 * @return
	 *
	 */
	@AliasFor("userServiceType")
	Class<? extends IAutumnUserDetailsService> value() default AutumnUserServiceImpl.class;

	/**
	 * 用户服务类型
	 * 
	 * @return
	 *
	 */
	@AliasFor("value")
	Class<? extends IAutumnUserDetailsService> userServiceType() default AutumnUserServiceImpl.class;

	/**
	 * 加密类型
	 * 
	 * @return
	 *
	 */
	Class<? extends PasswordEncoder> passwordEncoderType() default BCryptPasswordEncoder.class;

	/**
	 * 密码驱动类型
	 * 
	 * @return
	 */
	Class<? extends IAutumnPasswordProvider> passwordProviderType() default AutumnUserDetailsBindingPasswordProvider.class;

	/**
	 * 安全适配类型
	 * 
	 * @return
	 */
	Class<? extends ZeroAuthenticationSecurityConfigurerAdapter> securityConfigurerAdapterType() default ZeroAuthenticationSecurityConfigurerAdapter.class;

	/**
	 * 服务器适配类型
	 * 
	 * @return
	 */
	Class<? extends ZoreAuthorizationServerConfigurerAdapter> serverConfigurerAdapterType() default ZoreAuthorizationServerConfigurerAdapter.class;
}
